{extend name="public:base" /}

{block name="content"}
<div class="page-header">
	<h1>	
		{$breadcrumb1}
		<small>
			<i class="ace-icon fa fa-angle-double-right"></i>
			{$breadcrumb2}
		</small>
	</h1>
</div>	
<div class="page-header">
	<a href="{:url('Article/add')}" class="btn btn-primary">新增</a>
</div>		
	
<table class="table table-striped table-bordered table-hover search-form">
	<thead>
		<th>
			<input name="id" type="text" placeholder="输入ID" value="{:input('id')}" />   
			&nbsp;&nbsp;&nbsp;
			<select name="status">
				<option value="">-所有状态-</option>
				<?php $status=input('param.status'); ?>
				<option {if condition="isset($status) and (1 eq $status)"} selected="selected"{/if} value="1">启用</option>
				<option {if condition="isset($status) and (0 eq $status)"} selected="selected"{/if} value="0">禁用</option>				
			</select>
			&nbsp;&nbsp;&nbsp;
			<a class="btn btn-primary" href="javascript:;" id="search" url="{:url('Article/index')}">查询</a>
		</th>
	</thead>
</table>	
	
<div class="row">
	<div class="col-xs-12">	
		<div class="table-responsive">
			<table class="table table-striped table-bordered table-hover">
				<thead>
					<tr>		
						<th>ID</th>									
						<th>标题</th>
						<th>发布者</th>
						<th>发布时间</th>  		
						<th>状态</th>  				
						<th>操作</th>				
					</tr>
				</thead>
				<tbody>
						{volist name="list" id="d" empty="$empty"}
						<tr>		
							<td>{$d.id}</td>					
							<td>{$d.title}</td>
							<td>{$d.author}</td>
							<td>{$d.create_time|date="Y-m-d",###}</td>		
							<td>
							{switch name="d.status"}
								{case value="1"}<a href='{:url("Article/set_status",array("id"=>$d["id"],"status"=>0))}'><span title="启用" class="btn btn-xs btn-success"><i class="fa fa-check bigger-120"></i></span></a>{/case}
								{case value="0"}<a href='{:url("Article/set_status",array("id"=>$d["id"],"status"=>1))}'><span title="禁用" class="btn btn-xs btn-danger"><i class="fa fa-remove bigger-120"></i></span></a>{/case}
							{/switch}
							</td>						
							<td>
								<a class="btn btn-xs btn-info" href='{:url("Article/edit",array("id"=>$d["id"]))}' title="查看">
									<i class="fa fa-eye bigger-120"></i>
								</a>
								<a class="delete btn btn-xs btn-danger" href='{:url("Article/del",array("id"=>$d["id"]))}' title="删除" >
									<i class="fa fa-trash bigger-120"></i>
								</a>
							</td>
						</tr>
						{/volist}	
						
						<tr>
							<td colspan="20" class="page">{$list->render()}</td>
						</tr>
						<tr>
							<td colspan="20">总计 {$list->total()|default="0"} 个话题</td>
						</tr>
				</tbody>
				
			</table>
		</div>
	</div>
</div>
{/block}
{block name="javascript"}
<script>	
$(function(){
   $("#search").click(function () {
        var url = $(this).attr('url');
        var query = $('.search-form').find('input,select').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
        query = query.replace(/^&/g, '');
        if (url.indexOf('?') > 0) {
            url += '&' + query;
        } else {
            url += '?' + query;
        }
        window.location.href = url;
    });	
});
</script>
{/block}